﻿using System;
using System.Linq.Expressions;

namespace Emico.Linq.Criterion
{
    public abstract class AbstractExpression<T> : IExpression<T>
        where T : class
    {
        #region ICriterion Members

        public abstract Expression ToLinqExpression(Criteria<T> criteria, ParameterExpression parameter);

        #endregion

        #region Operator Overloading

        public static AbstractExpression<T> operator &(AbstractExpression<T> lhs, AbstractExpression<T> rhs)
        {
            return new AndExpression<T>(lhs, rhs);
        }

        public static AbstractExpression<T> operator |(AbstractExpression<T> lhs, AbstractExpression<T> rhs)
        {
            return new OrExpression<T>(lhs, rhs);
        }

        #endregion

        #region ISerializable

        public abstract void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);

        #endregion
    }
}
